package org.example.zuoye.api;

import org.example.zuoye.service.UploadFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @Author xinchen
 * @Date: 2024/08/12/ 19:38
 * @Description 图片上传api
 */
@RestController
@RequestMapping("/api/v1/uploads")
public class UploadFileApi {

    @Autowired
    private UploadFileService uploadFileService;

    @PostMapping("/avatar")
    public Map<String, Object> uploadAvatar(MultipartFile file) {
        String url = this.uploadFileService.uploadAvatar(file);
        return Map.of("success", true,"url",url);
    }
}
